﻿using MediatR;
using System.CJL.API.Application.Command.StorageCommand;
using System.CJL.Infrstructre.Interface;

namespace System.CJL.API.Application.CommandHanlder.StorageCommandHandler
{
    /// <summary>
    /// 删除
    /// </summary>
    public class StorageDeleteCommandHandler : IRequestHandler<StorageDeleteCommand,int>
    {
        IStorageRepository _storageRepository;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="storageRepository"></param>
        public StorageDeleteCommandHandler(IStorageRepository storageRepository)
        {
            _storageRepository=storageRepository;
        }

        public async Task<int> Handle(StorageDeleteCommand request, CancellationToken cancellationToken)
        {
            var list = await _storageRepository.GetMondel(request.id);
            list.IsDelete= true;
            list.DelectName = "张三";
            list.DelectTime = DateTime.Now.ToUniversalTime();
            int result = await _storageRepository.UpdateAsync(list);
            return result;
        }
    }
}
